<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="Dao.*,java.util.*,vo.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<title>主页</title>
<!-- Bootstrap 核心CSS -->
<link rel="stylesheet" href="https://code.z01.com/v4/dist/css/bootstrap.min.css">
<style>
/* * Globals */
/* Links */
a, a:focus, a:hover { color: #fff; }
/* Custom default button */
.btn-secondary, .btn-secondary:hover, .btn-secondary:focus { color: #333; text-shadow: none; /* Prevent inheritance from `body` */ background-color: #fff; border: .05rem solid #fff; }
/* * Base structure */
html, body { height: 100%; background-color: #333; }
body { color: #fff; text-align: center; text-shadow: 0 .05rem .1rem rgba(0,0,0,.5); }
/* Extra markup and styles for table-esque vertical and horizontal centering */
.site-wrapper { display: table; width: 100%; height: 100%; /* For at least Firefox */ min-height: 100%; box-shadow: inset 0 0 5rem rgba(0,0,0,.5); }
.site-wrapper-inner { display: table-cell; vertical-align: top; }
.cover-container { margin-right: auto; margin-left: auto; }
/* Padding for spacing */
.inner { padding: 2rem; }
/* * Header */
.masthead { margin-bottom: 2rem; }
.masthead-brand { margin-bottom: 0; }
.nav-masthead .nav-link { padding: .25rem 0; font-weight: 700; color: rgba(255,255,255,.5); background-color: transparent; border-bottom: .25rem solid transparent; }
.nav-masthead .nav-link:hover, .nav-masthead .nav-link:focus { border-bottom-color: rgba(255,255,255,.25); }
.nav-masthead .nav-link + .nav-link { margin-left: 1rem; }
.nav-masthead .active { color: #fff; border-bottom-color: #fff; }

@media (min-width: 48em) {
.masthead-brand { float: left; }
.nav-masthead { float: right; }
}
/* * Cover */
.cover { padding: 0 1.5rem; }
.cover .btn-lg { padding: .75rem 1.25rem; font-weight: 700; }
/* * Footer */
.mastfoot { color: rgba(255,255,255,.5); }
/* * Affix and center */
@media (min-width: 40em) {
/* Pull out the header and footer */
.masthead { position: fixed; top: 0; }
.mastfoot { position: fixed; bottom: 0; }
/* Start the vertical centering */
.site-wrapper-inner { vertical-align: middle; }
/* Handle the widths */
.masthead,  .mastfoot,  .cover-container { width: 100%; /* Must be percentage or pixels for horizontal alignment */ }
}
@media (min-width: 62em) {
.masthead,  .mastfoot,  .cover-container { width: 42rem; }
}
</style>
</head>
<body background="../pic/333.jpg" style="background-size:100%;">
<div class="site-wrapper">
  <div class="site-wrapper-inner">
    <div class="cover-container">
      <header class="masthead clearfix">
        <div class="inner">
          <h6 class="masthead-brand">Power By &nbsp</h6>
          <h3 class="masthead-brand">GSC</h3>
          <nav class="nav nav-masthead"> 
          <a class="nav-link" href="Zhuye.jsp">Home</a> 
          <a class="nav-link" href="user.jsp">User</a> 
          <a class="nav-link  active" href="user_select.jsp">Select</a>
          <a class="nav-link" href="Login_out.jsp">Exit</a> 
          </nav>
        </div>
      </header>
      <main role="main" class="inner cover" >
       <form class="form-inline"  action="user_select.jsp" method="post" target="_blank" > 
       <div class="input-group" > 
       <input  class="form-control"  name="username" type="text" placeholder="用户昵称搜索"  style="margin-left: 200px;"> 
       <div class="input-group-append">
        <button class="input-group-text" type="submit" onclick="xianshi()">
       <i class="zi zi_search" >搜索</i>
       </button>  
       </div></div>
       </form>
      </main>

      <br>
      <table class="table table-striped table-dark table-hover table-borderless" style="width:1200px;margin-left:-260px;border-radius:20px;">
  <thead>
    <tr>
      <th scope="col">用户编号</th>
      <th scope="col">用户姓名</th>
      <th scope="col">用户昵称</th>
      <th scope="col">性别</th>
      <th scope="col">邮箱</th>
      <th scope="col">电话</th>
      <th scope="col">操作</th>
      <th scope="col">操作</th>
    </tr>
  </thead>
  
<%
request.setCharacterEncoding("UTF-8");
String username = request.getParameter("username");//从搜索框提取的用户名

Userdao dao = new Userdao();
int i=0;


String thispage = request.getParameter("thispage");

int thispage2;
if(thispage==null){
	thispage2 = 0;
}else{
	thispage2 = Double.valueOf(thispage).intValue();
}
if(thispage2 < 0){
	thispage2 = 0;
}
if(username==null){
	username = "";
}

ArrayList<User> list2 = dao.do_SelectByUname(username);
double listsize=list2.size();
double listsize2 = Math.ceil(listsize/4.0)*4-4;

if(thispage2>listsize2){
	thispage2 = (int)listsize2;
}

int listsize3=(int)listsize2/4+1;

String p = thispage2/4+1+"/"+listsize3+"页";


ArrayList<User> list = dao.do_SelectByUname(username,thispage2);
Iterator<User> it = list.iterator();


	while(it.hasNext()){
		User user = it.next();
		int user_id =user.getUser_id();
	
	
	

%> 

  <tbody>
    <tr>
      <th scope="row"><%=user_id %></th>
      <td><%=user.getRealname() %></td>
      <td><%=user.getUsername() %></td>
      <td><%=user.getGender() %></td>
      <td><%=user.getEmail() %></td>
      <td><%=user.getPhone() %></td>
      <td><form action="user_delete.jsp?id=<%=user_id %>" method="post" name="del"><input class="btn btn-outline-danger" type="submit" onclick="delcfm()" value="删除" ></form></td>
      <td><a class="btn btn-outline-info" href="sys_change.jsp?id=<%=user_id %>" role="button">修改信息</a></td>
    </tr>
<%
	}
%>
  </tbody>
  
</table>
<a href="user_select.jsp?thispage=0&username=<%=username %>" class="btn btn-outline-light">首页</a>
<a href="user_select.jsp?thispage=<%=thispage2-4 %>&username=<%=username %>" class="btn btn-outline-light">上一页</a>
<a href="user_select.jsp?thispage=<%=thispage2+4 %>&username=<%=username %>" class="btn btn-outline-light">下一页</a>
<a href="user_select.jsp?thispage=<%=listsize2 %>&username=<%=username %>" class="btn btn-outline-light">尾页</a>
<a href="#" class="btn btn-outline-light"><%=p%></a>

    </div>
  </div>
</div>


<!-- Bootstrap 核心 JavaScript --> 
<script src="https://code.z01.com/js/jquery-3.2.1.slim.min.js"></script>
<script src="https://code.z01.com/v4/dist/js/popper.min.js"></script>
<script src="https://code.z01.com/v4/dist/js/bootstrap.min.js"></script>
<script type="text/javascript">

function delcfm() { 
    if (!confirm("确认要删除吗？")) { 
        window.event.returnValue = false;
    }
    del.submit();
} 
</script>
</body></html>